package sixkey.config.AlipayConfig;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * ClassName:AlipayConfig
 * Package:sixkey.config.AlipayConfig
 * Description
 *
 * @Author:@wenxueshi
 * @Create:2023/6/26 - 23:19
 * @Version:v1.0
 */
@Data
@Component
public class AlipayConfig implements InitializingBean {
    // 读取配置文件中的内容
    @Value("${alipay.alipayPublicKey}")
    private String alipayPublicKey;

    @Value("${alipay.appId}")
    private String appId;

    @Value("${alipay.gateway}")
    private String gateway;

    @Value("${alipay.appPrivateKey}")
    private String appPrivateKey;

    @Value("${alipay.notifyUrl}")
    private String notifyUrl;

    @Value("${alipay.returnUrl}")
    private String returnUrl;

    // 在spring生命周期中 实例化->生成对象->属性填充后会进行afterPropertiesSet方法
    // 定义空开常用变量
    public static String ALIPAYPUBLICKEY;
    public static String APPID;
    public static String GATEWAY;
    public static String APPPRIVATEKEY;
    public static String NOTIFYURL;
    public static String RETURNURL;

    @Override
    public void afterPropertiesSet() throws Exception {
        ALIPAYPUBLICKEY = alipayPublicKey;
        APPID = appId;
        GATEWAY = gateway;
        APPPRIVATEKEY = appPrivateKey;
        NOTIFYURL = notifyUrl;
        RETURNURL = returnUrl;
    }
}
